package com.smyk.btchina.base

import android.widget.Toast
import androidx.viewbinding.ViewBinding
import com.smyk.btchina.net.api.NetStatus

/**
 * @des
 * @date 2021/8/5
 * @author sam
 */
abstract class BaseMvvmFragment <VB : ViewBinding, VM : BaseViewModel> : BaseFragment<VB>() {
    protected val mViewModel: VM by lazy { getViewModel() }

    abstract fun getViewModel(): VM

    override fun initData() {
        super.initData()
        mViewModel.netStatus.observe(this) {
            when (it) {
                NetStatus.LOADING -> {

                }
                NetStatus.COMPLETE -> {

                }
                NetStatus.ERROR -> {
                    Toast.makeText(
                        activity,
                        "Lỗi đường truyền, xin thử lại sau",
                        Toast.LENGTH_SHORT
                    ).show()
                }
                else -> {

                }
            }
        }
    }
}